#ifndef WORLD_H
#define WORLD_H

#include "ai.h"
#include "player.h"
#include "motiontracker.h"
#include "logger/logger.h"
#include <stdlib.h>
#include <OgreSceneManager.h>

#define COLLISION_RADIUS 80

// GAME SETTINGS

#define FEEDBACK 3 // 1 = none, 2 = tracker, 3 = grid
#define GESTURE_SET 1 // 1 = set 1, 2 = set 2
#define GAME_TYPE 1 // 1 = Training, 2 = Game

class Player;
class MotionTracker;

class World
{
public:
    World(Ogre::SceneManager *sceneManager);
    void worldStep(float time);
    int getCurrentTime();
    void addActor(AI* actor, Ogre::Vector3 position);
    void removeActor(AI* actor);
    void removeActor(int i);
    void createSprinter(int amount);
    void createFlyer(int amount);
    void createTestActor(int amount);
    void createBossRight(int amout);
    void createBossLeft(int amout);
    void createHealthPickup(int amout);
    void setScore(int score);

    Singleton *m_logger;

    Ogre::Entity* m_gesture[3];
    Ogre::SceneNode* m_gestNode[3];

    void setGestureRunning(bool gestureRunning);

    int m_controller;
    int m_gestCount;

    int getWidth(){
        return m_width;
    }

    int getHeight(){
        return m_height;
    }

    Player* getPlayer(){return m_player;}

    int getActorsCount(){ return m_actors.size();}
    AI* getActor(int index){return m_actors[index];}

    Ogre::SceneManager *getSceneManager(){return m_scene;}

    Ogre::Entity* numbers[10];
    Ogre::SceneNode* m_numberNodes[3];

    bool m_gestureRunning;
    int m_gestureTime;
    void deleteExternals();

private:
    void collisionDetection();
    void killDiedActors();
    void spawner();
    std::vector<AI*> m_actors;
    std::vector<int> m_actors_toDie;

    Player *m_player;
    MotionTracker *m_tracker;
    Ogre::SceneManager *m_scene;

    Ogre::Timer timer;
    int m_width;
    int m_height;
};

#endif // WORLD_H
